home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / MacApp / MacApp 2.0 CD Release / MacApp 2.0 (Many Libraries) / Libraries / UMacAppUtilities.a < prev    next >
Encoding:
Text File  |  1990-03-27  |  5.9 KB  |  204 lines  |  [TEXT/MPS ]

  1. ;=============================================================================
  2. ; UMacAppUtilities assembly language routines
  3. ;
  4. ; KNOWN LIMITATIONS
  5. ;
  6. ; Copyright © 1987-1990 Apple Computer, Inc.  All rights reserved.
  7. ;
  8. ; when       who    what
  9. ; -------- ---- --------------------------------------------------------------
  10. ; 88.07.28 srf    add header and includes for Macros
  11. ; ----------------------------------------------------------------------------
  12.  
  13.                 Blanks        On
  14.                 String        AsIs
  15.                 Case        On
  16.  
  17.                 Print        Off
  18.                 Include     'Macros.a'
  19.  
  20.                 LOAD            'ProgStrucMacs.d'
  21.                 LOAD            'FlowCtlMacs.d'
  22.                 Print        On
  23.  
  24.  
  25. ;---------------------------------------------------------------------------------------------------
  26.  
  27. Initializers     Record
  28.                 Export        gToolBoxInitialized, gUGridViewInitialized, gUPrintingInitialized
  29.                 Export        gUTEViewInitialized, gUDialogInitialized
  30. gToolBoxInitialized        DC.W        0                    ; Boolean: if Toolbox is inited
  31. gUDialogInitialized        DC.W        0                    ; Boolean: if UDialog inited
  32. gUGridViewInitialized    DC.W        0                    ; Boolean: if UGridView inited
  33. gUPrintingInitialized    DC.W        0                    ; Boolean: if UPrinting inited
  34. gUTEViewInitialized        DC.W        0                    ; Boolean: if UTEView inited
  35.                 EndR
  36.  
  37. UMacAppUtilitiesGlobals     Record
  38.                 Export        gStrippedAddress, gApplication
  39. gStrippedAddress        DC.L        0                    ; an address already stripped by StripAddress
  40.                                                         ; will be initialized by inittoolbox
  41. gApplication            DC.L        0                    ; the application object
  42.                 EndR
  43.             
  44. ;---------------------------------------------------------------------------------------------------
  45. ;    FUNCTION  EqualBlocks(first, second: UNIV Ptr; theSize: INTEGER): BOOLEAN;
  46. ;    Returns true if blocks pointed to by 'first' and 'second' are equal over
  47. ;    'theSize' number of bytes.
  48. ;    Trashes:    D0,D1,A0,A1
  49.  
  50.                 Seg         'MAUtilitiesRes'
  51. EXPORT FUNCTION EQUALBLOCKS(first:L, second:L, theSize):B
  52.     VAR            addrStore:L
  53.  
  54.     BEGIN
  55.                 
  56.                 Move.B        #1,EQUALBLOCKS(FP)        ; Prime result to TRUE
  57.                 
  58.                 Move.L        first(FP),A0        ; Point at data blocks
  59.                 Move.L        second(FP),A1
  60.                 Move        theSize(FP),D0        ; Fetch count
  61.  
  62. * handle odd-addressing
  63.                 Tst            D0                    ; Anything to compare?
  64.                 Beq.S        @4                    ; Nope, we're done
  65.                 Move.L        A0,addrStore(FP)
  66.                 Move.L        addrStore(FP),D1    ; Work with address
  67.                 And            #1,D1                ; Is it odd?
  68.                 Beq.S        @0                    ; If it ain't, go on to normal stuff
  69.                 CmpM.B        (A0)+,(A1)+            ; Check the odd address
  70.                 Bne.S        @3                    ; Not equal, so punt
  71.                 SubQ        #1,D0                ; One less value to check
  72.  
  73. * even-addressing
  74.         @0:        Move        D0,D1                ; Sub-long count
  75.                 And         #3,D1
  76.                 LsR         #2,D0                ; Long count
  77.                 Beq.S        @1                    ; No longs, so try sub-longs
  78.                 SubQ        #1,D0                ; Back off one for DBeq
  79.                 
  80.         @2:     CmpM.L        (A0)+,(A1)+         ; Compare values
  81.                 DBne        D0,@2
  82.                 Bne.S        @3                    ; Not equal, so punt
  83.                 
  84.         @1:     Tst         D1                    ; Any sub-longs?
  85.                 Beq.S        @4                    ; Nope, we're done
  86.                 SubQ        #1,D1                ; Back off one for DBeq
  87.                 
  88.         @5:     CmpM.B        (A0)+,(A1)+         ; Compare values
  89.                 DBne        D1,@5
  90.                 
  91.                 Beq.S        @4                    ; Equal, so we're done
  92.                 
  93.         @3:     Clr.B        EQUALBLOCKS(FP)     ; Signal false
  94.         
  95.         @4:     Return
  96.                 ENDF
  97.  
  98.  
  99.  
  100.         If not qNeedsROM128K then
  101. ;---------------------------------------------------------------------------------------------------
  102. ;    FUNCTION  CompareStrings(first, second: UNIV Ptr; theSize: INTEGER): INTEGER;
  103. ;    Returns -1, 0, or 1 if first is <, =, or > second.
  104. ;    Trashes:    D0,D1,D2,A0,A1
  105.  
  106.                 Seg         'MAUtilitiesRes'
  107. COMPARESTRINGS    PROC        EXPORT
  108.  
  109. StackFrame        Record        {A6Link},Decrement
  110. RetValue        Ds.W        1    ; 10
  111.  
  112. ArgSize            Equ            *-8
  113. first            Ds.L        1    ; 0C
  114. second            Ds.L        1    ; 08
  115.  
  116. RetAddr            Ds.L        1    ; 04
  117. A6Link            Ds.L        1    ; 00
  118. LocalSize        Equ            *
  119.                 EndR
  120.  
  121.                 With        StackFrame
  122.                 
  123.                 Link        A6,#LocalSize
  124.                 Move.W        #0,RetValue(A6)        ; Prime result to equal
  125.                 
  126.                 Move.L        first(A6),A0        ; Point at strings
  127.                 Move.L        second(A6),A1
  128.                 Clr.W        D0
  129.                 Move.B        (A0)+,D0            ; D0 = length of first string.
  130.                 Clr.W        D1
  131.                 Move.B        (A1)+,D1            ; D1 = length of second string.
  132.                 Cmp.W        D0,D1                ; Which string is shorter?
  133.                 Blt.S        @1                    ; The A1 string is, use its length.
  134.                 Move.W        D0,D2                ; The A2 string is, use its length.
  135.                 Beq.S        CmpLengths            ; If it's an empty string, just compare lengths
  136.                 Bra.S        @2
  137. @1
  138.                 Move.W        D1,D2                ; The A1 string is shorter.
  139.                 Beq.S        CmpLengths            ; If its an empty string, only compare lengths.
  140. @2
  141.                 SubQ.W        #1,D2;                ; Adjust for DBNE loop
  142. CmpStrings
  143.                 CmpM.B        (A0)+,(A1)+            ; Compare strings up to the length of the
  144.                 DBNE        D2,CmpStrings        ; …shorter string.
  145.                 Blt.S        FirstGTLast
  146.                 Bgt.S        FirstLTLast
  147. CmpLengths
  148.                 Cmp.W        D0,D1                ; Common part is equal, compare lengths
  149.                 BEq.S        Exit
  150.                 Blt.S        FirstGTLast
  151. FirstLTLast
  152.                 Move.W        #-1,RetValue(A6)
  153.                 Bra.S        Exit
  154. FirstGTLast
  155.                 Move.W        #1,RetValue(A6)
  156. Exit
  157.                 Unlk        A6
  158.                 Move.L        (SP)+,A0            ; Return address
  159.                 Lea            ArgSize(SP),SP        ; Clean up stack
  160.                 Jmp            (A0)                ; Return to caller
  161.  
  162.                 EndProc
  163.         Endif
  164.  
  165. ;---------------------------------------------------------------------------------------------------
  166. ;    PROCEDURE FieldToString (theData: Ptr; fieldType: INTEGER; VAR theString: Str255);
  167. ;    Calls the routine pointed to by gFieldToStrRtn (defined in UMacAppUtilities.p).
  168. ;    Trashes:    D0,D1,A0,A1
  169.  
  170.                 Seg         'MAUtilitiesRes'
  171. EXPORT PROCEDURE FIELDTOSTRING
  172.  
  173.     BEGIN
  174.     If qNames Then
  175.                 Move.L    (SP)+,A6    ; straighten up stack from Link A6
  176.     EndIf
  177.                 Move.L        GFIELDTOSTRRTN,A0
  178.                 JMP         (A0)
  179.                 Return
  180.  
  181.         DATA
  182.                 Export        GFIELDTOSTRRTN:Data
  183. GFIELDTOSTRRTN        DC.L        0
  184.  
  185.                 ENDP
  186.  
  187. ;---------------------------------------------------------------------------------------------------
  188. ; FUNCTION StripLong(address: UNIV Ptr): LONGINT;
  189. ; Masks address with a pre-stripped address to avoid icky StripAddress glue !
  190. ; Can't use "C" attribute for function since Think™ Pascal can't take the heat (TP 3.0)
  191. ;    Trashes:    D0
  192.  
  193.                 Seg         'MAUtilitiesRes'
  194. EXPORT FUNCTION STRIPLONG(address:L):L
  195.  
  196.     BEGIN with=UMacAppUtilitiesGlobals
  197.                 MOVE.L        gStrippedAddress(A5),D0
  198.                 AND.L        address(FP),D0
  199.                 MOVE.L        D0, STRIPLONG(FP) 
  200.                 Return
  201.                 ENDP
  202.  
  203.                 END
  204.